﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="LoadDevicesCommand.cs" company="">
//   
// </copyright>
// <summary>
//   The load devices command.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace F5.BigIp.LocalTrafficManager.UI.Commands
{
    using System;
    using System.Windows.Input;

    using F5.BigIp.LocalTrafficManager.Interfaces;
    using F5.BigIp.LocalTrafficManager.UI.ViewModels;
    using System.Collections.ObjectModel;

    /// <summary>The load devices command.</summary>
    public class LoadDevices : ICommand
    {
        #region Fields

        /// <summary>The view model.</summary>
        private readonly MainViewModel viewModel;

        #endregion

        #region Constructors and Destructors

        /// <summary>Initializes a new instance of the <see cref="LoadDevices"/> class.</summary>
        /// <param name="viewModel">The view model.</param>
        public LoadDevices(MainViewModel viewModel)
        {
            this.viewModel = viewModel;
        }

        #endregion

        #region Public Events

        /// <summary>The can execute changed.</summary>
        public event EventHandler CanExecuteChanged
        {
            add
            {
                CommandManager.RequerySuggested += value;
            }

            remove
            {
                CommandManager.RequerySuggested -= value;
            }
        }

        #endregion

        #region Public Methods and Operators

        /// <summary>The can execute.</summary>
        /// <param name="parameter">The parameter.</param>
        /// <returns>The <see cref="bool"/>.</returns>
        public bool CanExecute(object parameter)
        {
            return true;
        }

        /// <summary>The execute.</summary>
        /// <param name="parameter">The parameter.</param>
        public void Execute(object parameter)
        {
            this.viewModel.LoadBalancers = new ObservableCollection<LoadBalancer>()
                                         {
                                             //Add loadbalancers here
                                         };
        }

        #endregion
    }
}